<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if(!function_exists('upload_file_image')){
    function upload_file_image($path,$filename,$isOver){
        $CI =& get_instance();
        $config['upload_path'] = $path;
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']	= FILE_SIRE_UPLOAD;
        $config['remove_spaces'] = TRUE;
        $config['overwrite'] = $isOver;
        $config['file_name']= $filename;
        $CI->load->library('upload', $config);

        if ( ! $CI->upload->do_upload('pfile'))
        {
            $error = array('error' => $CI->upload->display_errors('',''));
            return $error;
        }
        else
        {
            $data = array('upload_data' => $CI->upload->data());
            return $data;
        }
    }
}
if(!function_exists('resize_image')){
    function resize_image($image,$width,$height){
        $CI =& get_instance();
        $config['image_library'] = 'gd2';
        $config['source_image']	= $image;
        $config['create_thumb'] = FALSE;
        $config['maintain_ratio'] = TRUE;
        $config['width']	 = $width;
        $config['height']	= $height;
        $CI->load->library('image_lib', $config);
        $CI->image_lib->resize();
    }
}
if(!function_exists('resize_image_thumb')){
    function resize_image_thumb($image,$width,$height){
        $CI =& get_instance();
        $config['image_library'] = 'gd2';
        $config['source_image']	= $image;
        $config['create_thumb'] = TRUE;
        $config['maintain_ratio'] = TRUE;
        $config['width']	 = $width;
        $config['height']	= $height;
        $CI->load->library('image_lib', $config);
        $CI->image_lib->resize();
    }
}
